package org.moflon.boardgamegui.view.menubar.actions;

import org.apache.log4j.BasicConfigurator;
import org.eclipse.jface.action.Action;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.FileDialog;
import org.moflon.boardgamegui.view.View;

public class LoadAction extends Action {
	View view;

	public LoadAction(View view) {
		this.view = view;
		setText("Load");
		setToolTipText("Load saved board");

	}

	public void run() {
		BasicConfigurator.configure();

		// Create a file chooser
		FileDialog fileDialog = new FileDialog(view.getShell(), SWT.OPEN);
		fileDialog.setFileName("instances/");
		String[] extensions = { "*.xmi" };
		fileDialog.setFilterExtensions(extensions);
		String filePath = fileDialog.open();

		if (filePath != null)
			view.getController().loadModel(filePath);
	}

}
